-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle failure when enabling bracketed paste #9353
Conversation
not sure i've handled the ok match arm correctly :/ |
helix-tui/src/backend/crossterm.rs
Outdated
@@ -131,12 +131,22 @@ where | |||
{ | |||
fn claim(&mut self, config: Config) -> io::Result<()> { | |||
terminal::enable_raw_mode()?; | |||
execute!( | |||
match execute!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The execute!
for EnableBracketedPaste
should be separated from the other terminal commands so that if the other commands fail we bail.
Also we need to track whether the terminal supports bracketed paste so that we can decide not to send DisableBracketedPaste
in restore
:
match execute!(self.buffer, EnableBracketedPaste) {
Err(err) if err.kind() == io::ErrorKind::Unsupported => {
log::warn!("Bracketed paste is not supported on this terminal.");
self.supports_bracketed_paste = false;
}
Err(err) => return Err(err),
Ok(_) => (),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force_restore
also needs to be modified so that it calls
let _ = execute!(stdout, DisableBracketedPaste);
rather than bailing when it isn't supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do i need to modify the trait method here to accept self?
or is there another way to check the supports_bracketed_paste field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force_restore
is called from a panic handler so there's no way to pass in information like the crossterm backend. Instead we have to execute the commands directly against stdout and in this case we can execute DisableBracketedPaste
and then just discard the Result so that we continue restoring the terminal even when it gives Err(Error::Unsupported)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we just bind it to the throwaway and remove it from the execute! at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep exactly 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* match instead of crash * pulling bracketedpaste out, refactor, tracking for bracketed paste * sending disable bracketed paste only when supports true * move disable bracketed paste to throwaway
* match instead of crash * pulling bracketedpaste out, refactor, tracking for bracketed paste * sending disable bracketed paste only when supports true * move disable bracketed paste to throwaway
* match instead of crash * pulling bracketedpaste out, refactor, tracking for bracketed paste * sending disable bracketed paste only when supports true * move disable bracketed paste to throwaway
* match instead of crash * pulling bracketedpaste out, refactor, tracking for bracketed paste * sending disable bracketed paste only when supports true * move disable bracketed paste to throwaway
* match instead of crash * pulling bracketedpaste out, refactor, tracking for bracketed paste * sending disable bracketed paste only when supports true * move disable bracketed paste to throwaway
match statement instead of crash for #9336